package classes
{
	import flash.display.BitmapData;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	import mx.controls.Alert;
	import mx.effects.Move;

	public class Bola
	{
		public static const MOVEMENT_TIME_PER_N_PIXELS:int = 400;
		public static const N_PIXELS:int = 50;
		private var xPos:Number, yPos:Number, radio:Number;
		private var move:Move;
		
		public function Bola(_move:Move)
		{
			xPos = new Number(300);
			yPos = new Number(300);
			radio = new Number(10);
		
			move = _move;
			move.end();
			move.xTo = xPos;
			move.yTo = yPos;
			move.duration = 1;
			move.play();
		}
		
		public function moveTo(newX:Number, newY:Number) {
			var time:Number = Math.round(Math.sqrt(Math.pow(xPos-radio-newX, 2) + Math.pow(yPos-radio-newY, 2)) / N_PIXELS) * MOVEMENT_TIME_PER_N_PIXELS;
			xPos = newX;
			yPos = newY;
			move.end();
			move.xTo = xPos-radio;
			move.yTo = yPos-radio;
			move.duration = time;
			move.play();
			
		}
	}
}